#define _CRT_SECURE_NO_WARNINGS 1

#include"HashTable.h"

namespace zzx {
	template<class K, class V, class Hash = HashFunc<K>>
	class unordered_map {
	public:
		struct MapKeyOfT {
			const K& operator()(const pair<K, V>& kv)
			{
				return kv.first;
			}
		};

		typedef typename HashTable<K, pair<K, V>, MapKeyOfT, Hash>::iterator iterator;

		iterator find(const K& key)
		{
			return _hs.find(key);
		}

		pair<iterator, bool> insert(const pair<K, V>& kv)
		{
			return _hs.insert(kv);
		}

		V& operator[](const K& key)
		{
			pair<iterator, bool> ret = insert(make_pair(key, V()));
			return ret.first->second;
		}
		
		bool erase(const K& key)
		{
			return _hs.erase(key);
		}

		iterator begin()
		{
			return _hs.begin();
		}

		iterator end()
		{
			return _hs.end();
		}

	private:
		HashTable<K, pair<K, V>, MapKeyOfT, Hash> _hs;
	};
}